﻿#include <CommonUnits/Units/Frequency.h>
#include <gtest/gtest.h>

TEST(FrequencyTest, CastTest)
{
    EXPECT_EQ(CU::Hertz(1e3), CU::Kilohertz(1));
    EXPECT_EQ(CU::Kilohertz(1e3), CU::Megahertz(1));
    EXPECT_EQ(CU::Megahertz(1e3), CU::Gigahertz(1));
    EXPECT_EQ(CU::Gigahertz(1e3), CU::Terahertz(1));
    EXPECT_EQ(CU::Terahertz(1e3), CU::Petahertz(1));
    EXPECT_EQ(CU::Petahertz(1e3), CU::Exahertz(1));
}

TEST(FrequencyTest, Literals)
{
    using namespace CU::Frequency::Literals;
    EXPECT_EQ(1e3_Hz, 1.0_kHz);
    EXPECT_EQ(1e3_kHz, 1.0_MHz);
    EXPECT_EQ(1e3_MHz, 1.0_GHz);
    EXPECT_EQ(1e3_GHz, 1.0_THz);
    EXPECT_EQ(1e3_THz, 1.0_PHz);
    EXPECT_EQ(1e3_PHz, 1.0_EHz);
}

TEST(FrequencyTest, ToUnit)
{
    using namespace CU::Frequency::Literals;
    EXPECT_EQ(1e3_Hz, CU::Frequency::toUnit<CU::Hertz>(1, CU::Kilohertz::unit()));
    EXPECT_EQ(1e3_kHz, CU::Frequency::toUnit<CU::Kilohertz>(1, CU::Megahertz::unit()));
    EXPECT_EQ(1e3_MHz, CU::Frequency::toUnit<CU::Megahertz>(1, CU::Gigahertz::unit()));
    EXPECT_EQ(1e3_GHz, CU::Frequency::toUnit<CU::Gigahertz>(1, CU::Terahertz::unit()));
    EXPECT_EQ(1e3_THz, CU::Frequency::toUnit<CU::Terahertz>(1, CU::Petahertz::unit()));
    EXPECT_EQ(1e3_PHz, CU::Frequency::toUnit<CU::Petahertz>(1, CU::Exahertz::unit()));
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}